import 'package:basic_common/app_theme.dart';
import 'package:basic_common/common_exports.dart';

class InfoRecordController extends GetxController  with GetSingleTickerProviderStateMixin{
  String type = Get.arguments["type"];
  ScrollController? scrollController;
  final isAppBArPinned = false.obs; //判断APPbar是否吸顶
  double kExpandedHeight = ScreenHelper.width(280);
  final weightValue = 50.0.obs;
  final bgColor = AppTheme.bluetextColor.obs;
  final typeName = "体重".obs;
  final unit = "Kg".obs; //单位
  TabController? tabController;
  @override
  void onInit() {
    // TODO: implement onInit
    scrollController = ScrollController()..addListener(_onScroll);
    tabController=TabController(length: 2, vsync: this);
    super.onInit();
    switchType();
  }

// 根据类型判断
  switchType() {
    switch (type) {
      case "weight":
        bgColor.value = AppTheme.bluetextColor;
        typeName.value = "体重";
        unit.value = "Kg";
        weightValue.value = 50.0;
        break;
      case "sugar":
        bgColor.value = AppTheme.purpletextColor;
        typeName.value = "血糖";
        unit.value = "mmol/L";
        weightValue.value = 9.0;
        break;
      case "press":
        bgColor.value = AppTheme.primyColor;
        typeName.value = "血压";
        unit.value = "mmHg";
        weightValue.value = 90.0;

        break;
      case "heart":
        bgColor.value = AppTheme.redtextColor;
        typeName.value = "心率";
        unit.value = "bmp";
        weightValue.value = 80.0;

        break;
    }
  }

  void _onScroll() {
    if (scrollController!.hasClients &&
        scrollController!.offset > kExpandedHeight - kToolbarHeight - 55) {
      isAppBArPinned.value = true;
    } else {
      isAppBArPinned.value = false;
    }
  }

  @override
  void onClose() {
    // TODO: implement onClose
    super.onClose();
    scrollController!.dispose();
  }
}
